Make GTK+ device grabs take precedence over GTK+ grabs
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 15 Jun 2010 17:06:51 +0000 (19:06 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 15 Jun 2010 17:39:59 +0000 (19:39 +0200)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=620440 (Reported by
Marek Kašík), where the print dialog modality would impair the pop-up
window from getting events. Device GTK+ grabs gain in specificness.

gtk/gtkmain.c

index c8c769f942992dda8392869ff525d9652b160fc9..017d000de1402df42f1619029fdb3ed17ffce00f 100644 (file)
@@ -1466,31 +1466,21 @@ gtk_main_do_event (GdkEvent *event)
   window_group = gtk_main_get_window_group (event_widget);
   device = gdk_event_get_device (event);
 
-  /* If there is a grab in effect...
+  /* check whether there is a (device) grab in effect...
    */
-  if (window_group->grabs)
-    {
-      grab_widget = window_group->grabs->data;
-      
-      /* If the grab widget is an ancestor of the event widget
-       *  then we send the event to the original event widget.
-       *  This is the key to implementing modality.
-       */
-      if (gtk_widget_is_sensitive (event_widget) &&
-         gtk_widget_is_ancestor (event_widget, grab_widget))
-       grab_widget = event_widget;
-    }
-  else if (device)
-    {
-      grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
+  if (device)
+    grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
 
-      if (grab_widget &&
-          gtk_widget_get_sensitive (event_widget) &&
-          gtk_widget_is_ancestor (event_widget, grab_widget))
-        grab_widget = event_widget;
-    }
+  if (!grab_widget && window_group->grabs)
+    grab_widget = window_group->grabs->data;
 
-  if (!grab_widget)
+  /* If the grab widget is an ancestor of the event widget
+   *  then we send the event to the original event widget.
+   *  This is the key to implementing modality.
+   */
+  if (!grab_widget ||
+      (gtk_widget_is_sensitive (event_widget) &&
+       gtk_widget_is_ancestor (event_widget, grab_widget)))
     grab_widget = event_widget;
 
   /* If the widget receiving events is actually blocked by another device GTK+ grab */